#pragma once
#include "../bondlib.h"
#include "../BondMarketStream.h"
#include <map>

class S_BONDLIB_EXPORT CTakenPriceMap{
	struct ClearPrice{
		char		m_price[12];				//收益率
	};
	struct TakenPrice{
		double		price;				// 净价
		double		yield;				// 收益率
		double		clean_price_div;	// 净价偏离度
		double		yield_div;			// 收益率偏离度
	};
	typedef std::map<BrokerKey,TakenPrice> PriceMap;
	typedef std::map<BrokerKey,ClearPrice>	ClearPriceMap;
	typedef std::map<BrokerKey, ClearPrice>	YieldPriceMap;
	PriceMap		m_prices;
	ClearPriceMap	m_clear_prices;
	YieldPriceMap	m_yield_prices;
	double			m_min_value;
	bool			m_with_yieldstr;
public:
	CTakenPriceMap();
	void SetWithYieldStr(bool withYieldStr){ m_with_yieldstr = withYieldStr; }
	double GetMinValue()const{ return m_min_value; }
	void Clear();
	void SetMap(int ncorpid,bool withString=false);
	const char* GetClearPriceStr(const BrokerKey& key);
	const char* GetYeildStr(const BrokerKey& key);
	double GetCleanPrice(const BrokerKey& key);
	double GetYield(const BrokerKey& key);
	double GetCleanPriceDiv(const BrokerKey& key);
	double GetYieldDiv(const BrokerKey& key);
	bool SetTakenPrice(const MarketStreamInfo& msi,bool withString);

public:
	double GetYieldCalc(const BrokerKey& key);
};